/**
 * Created by hooshim on 2014-12-04.
 */

var G_grid01 = "";
var G_page = 1;

$(document).ready(function() {
    fnGetSubMenus();
    fnSetCurMenu(2);
    fnGetLeftMenus('1');
    $("#_curMenu p").html("Express 요금")

    var bodyWidth = $('body').innerWidth();
    bodyWidth = parseInt(bodyWidth,10) - 170;
    $('#_bodyRight').css('width', bodyWidth + 'px');
    fnSetCurMenu(2);
    var gSubMenus = fnGetSubMenus();
    var gScreenHeight = parseInt($(window).height(),10) - 140;
    $("#_bodyLeft").css("height",gScreenHeight);
    $("#_bodyRight").css("height",gScreenHeight);
    gScreenHeight = parseInt(gScreenHeight,10) - 100;
    fnComboExpress('','expressCd');

    //var tmpData = $.parseJSON(gSubMenus);
    fnSetGrid01(gScreenHeight);
    fnGetList01(1);
});

var fnSetGrid01 = function(h) {

    var grdCd = "grid01";

    var widths = [70, 50, 50, 45, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70];
    var titles = ['익스프레스', '등급', '종류', '중량', '1지역', '2지역', '3지역', '4지역', '5지역', '6지역', '7지역', '8지역', '9지역', '10지역'];
    var styles = ['text-align:center;', 'text-align:center;', 'text-align:center;', 'text-align:center;', 'text-align:right;', 'text-align:right;', 'text-align:right;', 'text-align:right;', 'text-align:right;', 'text-align:right;', 'text-align:right;', 'text-align:right;', 'text-align:right;', 'text-align:right;'];

    var gInfo = new Object();
    gInfo["grdCd"] = "grid01";
    gInfo["title"] = "Express 요금표";
    gInfo["widths"] = widths;
    gInfo["titles"] = titles;
    gInfo["styles"] = styles;
    gInfo["fullWidth"] = "815";
    gInfo["fullHeight"] = h;
    gInfo["fix"] = "4";

    G_grid01 = JSON.stringify(gInfo);

    fnMkGridInit(G_grid01);
}

var fnGetList = function() {

    if(event.keyCode != "13")
    {
        return; // 엔터일때만 수행
    }
    fnGetList01(1);
}

var fnGetList01 = function(page) {
    fnMkGridLoad(G_grid01);
    if (page) G_page = page;
    else page = G_page;
    var param  = "expressCd="+$("#expressCd").val();
    param += "&dcRate="+$("#dcRate").val();
    param += "&oilRate="+$("#oilRate").val();
    var valUrl = "./action/rateExpress/list.php";

    $.ajax({
        url: valUrl,
        type: 'POST',
        dataType: 'json',
        data: param,
        success: function(data){

            fnMkGrid(G_grid01,data);
            /*
            $("#table_body").html(list);
            $("#total_rows").html(data.TOTAL_ROW_COUNT);
            var paging = fnPaging('fnGetList', data.TOTAL_ROW_COUNT, page, 10);
            var pages = paging['prev'] + paging['pager'] + paging['next'];
            // alert(pages);
            $("#pager").html(pages);
            */
        },
        error: function(data){
            alert('Error!!');
            alert(data.responseText);
        }
    });
}